#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename:   01-packages-hdzx.sh
# Version:    1.0
# Date:       2020/05/21
# Author:     Lz
# Email:      lz843723683@gmail.com
# History：     
#             Version 1.0, 2020/05/21
# Function:   packages - 默认服务和软件包
# Out:        
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

## TODO : 测试收尾清除工作
#
PkgClean_FTHDZX(){
	return $TPASS
}


## TODO: 调用程序退出函数
#    In: $1 => 调用脚本结果值
PkgExit_FTHDZX(){
        # 调用退出函数，其中调用了clean相关函数
	Exit_FTLIB ${1}
}


## TODO: 用户界面
#
PkgUSAGE_FTHDZX(){
	USAGE_FTLIB "华电众信版本 - 默认服务和软件包"
}


## TODO : 测试前的初始化 
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other=> TCONF
PkgInit_FTHDZX(){
        # 调用初始化函数
	Init_FTLIB "PkgClean_FTHDZX"
        # 调用用户界面函数
 	PkgUSAGE_FTHDZX
}


## TODO ：默认开启sshd psacct network iptables crond auditd rsyslog smartd sysstat firewalld  kdump服务
#
PkgTest01_FTHDZX(){
        local svcArr="sshd psacct network crond auditd rsyslog smartd sysstat firewalld"

        SvcActiveArr_FTLIB "isActive" "no" "$svcArr"
        RetParse_FTLIB "要求已经激活以下服务 ${svcArr}" "False"

	SvcEnableArr_FTLIB "isEnable" "no" "$svcArr"
        RetParse_FTLIB "要求默认开启服务：$svcArr" "False"
}


## TODO ：默认开启acpid 服务
#
PkgTest02_FTHDZX(){
	AcpidEnable_FTGENREQ
}


## TODO ：1. 默认安装net-tools、iptables、vconfig、openssh、openssl-devel、redis server、 mysql8.0、 monit、 nmap、 docker-ce、telnet 、tcpdump、wireshark、tcpreplay、hiredis-devel、libhtp-devel、libnet-devel、libyaml-devel、llvm7.0、rust、pfring
# 	  2. mysql版本为8.0
#
PkgTest03_FTHDZX(){
	local pkgArr="net-tools iptables vconfig openssh openssl-devel redis server  mysql monit  nmap  docker-ce telnet  tcpdump wireshark tcpreplay hiredis-devel libhtp-devel libnet-devel libyaml-devel llvm7.0 rust pfring"

	PkgExistArr_FTLIB "isExist" "no" "yes" "$pkgArr"
	RetParse_FTLIB "要求默认安装：$pkgArr" "False"

	# 判断版本
	local cmd="mysql"
	VersionEQTest_FTLIB "$cmd" "--version" "Ver 8"
}


## TODO : Main
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other => TCONF
PkgMain_FTHDZX(){
	PkgInit_FTHDZX

	PkgTest01_FTHDZX

	PkgTest02_FTHDZX

	PkgTest03_FTHDZX

	return ${TPASS}	
}

PkgMain_FTHDZX
PkgExit_FTHDZX $?
